package com.tang.Date20240613;

import lombok.SneakyThrows;

/**
 * @author tmh
 * @date 2024/6/16 16:03
 * @description
 */
public class VolatileDemo {
    private static int number = 1;
    public static void main(String[] args) {
        Thread t1 = new Thread(new Runnable() {
            @SneakyThrows
            @Override
            public void run() {
                while (true) {
//                    Thread.sleep(3000);
                    System.out.println(number);
                }
            }
        });
        t1.start();
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                    number=number+3;
                    System.out.println("线程2:"+number);

            }
        });
        t2.start();
    }

}
